package com.hzy.fivepalace.admin.controller;

import com.hzy.fivepalace.admin.annotation.Login;
import com.hzy.fivepalace.admin.controller.base.BaseController;
import com.hzy.fivepalace.admin.service.AdminWxUserService;
import com.hzy.fivepalace.common.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/admin/wxUser")
@Validated
@Api(tags = "用户服务")
@Login
public class AdminWxUserController extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(AdminWxUserController.class);

    @Resource
    private AdminWxUserService adminWxUserService;

    /**
     * 获取用户团队列表
     * @param page
     * @param size
     * @param userId
     * @return
     */
    @PostMapping("/getUserTeamList")
    @ApiOperation(value = "获取用户团队列表")
    public TableDataInfo getUserTeamList(
            @ApiParam(value = "页码", defaultValue = "1") @RequestParam(defaultValue = "1") Integer page,
            @ApiParam(value = "分页大小", defaultValue = "10") @RequestParam(defaultValue = "10") Integer size,
           @ApiParam(value = "用户id",required = true)@RequestParam(value = "userId")@NotNull  Integer userId
    ) {
        return adminWxUserService.getUserTeamList(page, size,userId);
    }

    /**
     * 获取用户积分明细列表
     * @param page
     * @param size
     * @param userId
     * @return
     */
    @PostMapping("/getUserPointsDetailList")
    @ApiOperation(value = "获取用户积分明细列表")
    public TableDataInfo getUserPointsDetailList(
            @ApiParam(value = "页码", defaultValue = "1") @RequestParam(defaultValue = "1") Integer page,
            @ApiParam(value = "分页大小", defaultValue = "10") @RequestParam(defaultValue = "10") Integer size,
            @ApiParam(value = "用户id",required = true)@RequestParam(value = "userId")@NotNull  Integer userId
    ) {
        return adminWxUserService.getUserPointsDetailList(page, size,userId);
    }


    /**
     * 获取用户佣金明细列表
     * @param page
     * @param size
     * @param userId
     * @return
     */
    @PostMapping("/getUserCommissionDetailList")
    @ApiOperation(value = "获取用户佣金明细列表")
    public TableDataInfo getUserCommissionDetailList(
            @ApiParam(value = "页码", defaultValue = "1") @RequestParam(defaultValue = "1") Integer page,
            @ApiParam(value = "分页大小", defaultValue = "10") @RequestParam(defaultValue = "10") Integer size,
            @ApiParam(value = "用户id",required = true)@RequestParam(value = "userId")@NotNull  Integer userId
    ) {
        return adminWxUserService.getUserCommissionDetailList(page, size,userId);
    }

    /**
     * 用户列表
     *
     * @param page
     * @param size
     * @return
     */
    @PostMapping("/getUserList")
    @ApiOperation(value = "用户列表")
    public TableDataInfo getUserList(
            @ApiParam(value = "状态:为空就查所有,0可用,1禁用,2注销") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(value = "用户昵称") @RequestParam(value = "nickname", required = false) String nickname,
            @ApiParam(value = "手机号码") @RequestParam(value = "phone", required = false) String phone,
            @ApiParam(value = "页码", defaultValue = "1") @RequestParam(defaultValue = "1") Integer page,
            @ApiParam(value = "分页大小", defaultValue = "10") @RequestParam(defaultValue = "100") Integer size
    ) {
        return adminWxUserService.getUserList(status, nickname, phone, page, size);
    }

    /**
     * 启用禁用
     *
     * @param userId
     * @param status
     * @return
     */
    @PostMapping("/updateUserStatus")
    @ApiOperation(value = "启用禁用")
    public Object updateUserStatus(@ApiParam(value = "用户id") @RequestParam @NotNull Integer userId,
                                   @ApiParam(value = "0启用,1禁用") @RequestParam @NotNull Integer status) {
        return adminWxUserService.updateUserStatus(userId, status);
    }

}
